package main

import (
	product_controller "gorm-demo/controller/product"
	user_controller "gorm-demo/controller/user"
	"gorm-demo/database"
	"gorm-demo/entity"

	"github.com/gin-gonic/gin"
)

func main() {
	r := gin.Default()
	database.Init()
	database.DB.AutoMigrate(&entity.User{})
	r.GET("/ping", func(c *gin.Context) {
		c.JSON(200, gin.H{
			"message": "pong",
		})
	})
	r.POST("/api/user/add", user_controller.AddUser)
	r.POST("/api/product/add", product_controller.AddProduct)
	r.POST("/api/user/list", user_controller.GetUserList)
	r.POST("/api/user/olderthan", user_controller.GetUserOlderThan)
	r.POST("/api/user/usernamelike", user_controller.GetUserLike)
	r.POST("/api/user/updateUserById", user_controller.UpdateUserById)
	r.POST("/api/user/UpdateUsernameById", user_controller.UpdateUsernameById)
	r.POST("/api/user/deleteUserById", user_controller.DeleteUserById)
	r.POST("/api/user/getUserListBySql", user_controller.GetUserListBySql)
	r.POST("/api/user/updateUserAgeBySql", user_controller.UpdateUserAgeBySql)
	r.Run(":9000")
}
